package godget.client;

import java.util.Vector;

/**
 * stores and manages a go game
 * @author reimer
 * TEST für Henriks svn
 *
 */
public class GoGame {
	
	// enumeration type to store the state of a field
	public static enum EFieldState
	{
		EMPTY,
		WHITE,
		BLACK;
	}
	
	public static class FieldChange
	{
		public int row;
		public int column;
		public EFieldState state;
		
		public FieldChange(int row, int column, EFieldState state) 
		{
			super();
			this.row = row;
			this.column = column;
			this.state = state;
		}

		public FieldChange()
		{
			this( 0, 0, EFieldState.EMPTY );
		}
		
	}
	
	int size;
	EFieldState[][] field;
	
	public GoGame( int size)
	{
		super();
		this.size = size;
		this.field = new EFieldState[size][size];
		
		for ( int i = 0; i < size; i++)
		{
			for ( int j = 0; j < size; j++)
				this.field[i][j] = EFieldState.EMPTY;
		}
	}
	
	public GoGame()
	{
		this( 9 );
	}
	
	public Vector<FieldChange> SetStone( FieldChange turn )
	{
		Vector<FieldChange> result = new Vector<FieldChange>();
		// TODO: find out if this turn was legal and if yes what changed
		if ( this.field[turn.row][turn.column] != EFieldState.EMPTY )
			return result;
		this.field[turn.row][turn.column] = turn.state;
		result.add(turn);
		return result;
	}

}
